package com.awei.study.design.action.templateMethod;

/**
 * @Author liweilong
 * @Date 2024/8/13 19:07
 */
public class TemplateMethod {

    public static abstract class CookVegetable {

        public final void cooking() {
            this.pourOil();
            this.heatOil();
            this.pourVegetable();
            this.pourSauce();
            this.fry();
        }

        public void pourOil() {
            System.out.println("倒油");
        }

        public void heatOil() {
            System.out.println("热油");
        }

        public abstract void pourVegetable();

        public abstract void pourSauce();

        public void fry() {
            System.out.println("翻炒");
        }
    }

    public static class FryXiLanHua extends CookVegetable{

        @Override
        public void pourVegetable() {
            System.out.println("加入西兰花");
        }

        @Override
        public void pourSauce() {
            System.out.println("加入西兰花配料");
        }
    }

    public static class FryBaiCai extends CookVegetable{

        @Override
        public void pourVegetable() {
            System.out.println("加入白菜");
        }

        @Override
        public void pourSauce() {
            System.out.println("加入白菜配料");
        }
    }

    public static void main(String[] args) {
        FryXiLanHua fryXiLanHua = new FryXiLanHua();
        fryXiLanHua.cooking();

        FryBaiCai fryBaiCai = new FryBaiCai();
        fryBaiCai.cooking();
    }
}
